package com.bluefox.modules.system.domain;

import com.bluefox.jpa.model.AbstractAuditModel;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Set;

/**
 * @CLassName 部门
 * @Description TODO
 * @Author 孙峰
 * @Date 2020/1/1 18:03
 * @Version 1.0
 */
@Entity
@Getter
@Setter
@Table(name = "sys_dept")
public class SysDept extends AbstractAuditModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 父部门id
     */
    @Column(name = "parent_id", nullable = false)
    @NotNull
    private Long parentId;
    /**
     * 祖级列表
     */
    @Column(name = "ancestors", length = 50)
    private String ancestors;
    /**
     * 部门名称
     */
    @Column(name = "dept_name", nullable = false, length = 30)
    @NotBlank
    private String deptName;
    /**
     * 显示顺序
     */
    @Column(name = "order_num", nullable = false, length = 30)
    private Integer orderNum;

    /**
     * 负责人
     */
    @Column(name = "leader", length = 20)
    private String leader;

    /**
     * '联系电话'
     */
    @Column(name = "phone", length = 11)
    private String phone;
    /**
     * '邮箱'
     */
    @Column(name = "email", length = 50)
    private String email;
    /**
     * 部门状态（0正常 1停用）
     */
    @Column(name = "status", length = 1)
    private String status = "0";
    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @Column(name = "del_flag", length = 1)
    private String delFlag = "0";



    @JsonIgnore
    @ManyToMany(mappedBy = "sysDepts")
    private Set<SysRole> sysRoles;


}
